package com.company.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.company.common.annotation.Log;
import com.company.common.core.controller.BaseController;
import com.company.common.core.domain.AjaxResult;
import com.company.common.enums.BusinessType;
import com.company.system.domain.TableUsertransfer;
import com.company.system.service.ITableUsertransferService;
import com.company.common.utils.poi.ExcelUtil;
import com.company.common.core.page.TableDataInfo;

/**
 * 员工调动Controller
 * 
 * @author ruoyi
 * @date 2022-07-07
 */
@RestController
@RequestMapping("/system/usertransfer")
public class TableUsertransferController extends BaseController
{
    @Autowired
    private ITableUsertransferService tableUsertransferService;

    /**
     * 查询员工调动列表
     */
    @PreAuthorize("@ss.hasPermi('system:usertransfer:list')")
    @GetMapping("/list")
    public TableDataInfo list(TableUsertransfer tableUsertransfer)
    {
        startPage();
        List<TableUsertransfer> list = tableUsertransferService.selectTableUsertransferList(tableUsertransfer);
        return getDataTable(list);
    }

    /**
     * 导出员工调动列表
     */
    @PreAuthorize("@ss.hasPermi('system:usertransfer:export')")
    @Log(title = "员工调动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TableUsertransfer tableUsertransfer)
    {
        List<TableUsertransfer> list = tableUsertransferService.selectTableUsertransferList(tableUsertransfer);
        ExcelUtil<TableUsertransfer> util = new ExcelUtil<TableUsertransfer>(TableUsertransfer.class);
        util.exportExcel(response, list, "员工调动数据");
    }

    /**
     * 获取员工调动详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:usertransfer:query')")
    @GetMapping(value = "/{personnelid}")
    public AjaxResult getInfo(@PathVariable("personnelid") Long personnelid)
    {
        return AjaxResult.success(tableUsertransferService.selectTableUsertransferByPersonnelid(personnelid));
    }

    /**
     * 新增员工调动
     */
    @PreAuthorize("@ss.hasPermi('system:usertransfer:add')")
    @Log(title = "员工调动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TableUsertransfer tableUsertransfer)
    {
        return toAjax(tableUsertransferService.insertTableUsertransfer(tableUsertransfer));
    }

    /**
     * 修改员工调动
     */
    @PreAuthorize("@ss.hasPermi('system:usertransfer:edit')")
    @Log(title = "员工调动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TableUsertransfer tableUsertransfer)
    {
        return toAjax(tableUsertransferService.updateTableUsertransfer(tableUsertransfer));
    }

    /**
     * 删除员工调动
     */
    @PreAuthorize("@ss.hasPermi('system:usertransfer:remove')")
    @Log(title = "员工调动", businessType = BusinessType.DELETE)
	@DeleteMapping("/{personnelids}")
    public AjaxResult remove(@PathVariable Long[] personnelids)
    {
        return toAjax(tableUsertransferService.deleteTableUsertransferByPersonnelids(personnelids));
    }
}
